
export default {
    state: {
        color_bg:'',
        show: false,
        input01: '',
        input02: {
            business_name: '',
            is_ip: '',
            is_business: '',
            bank_id: '',
            is_test: '',
            note: '',
            ip: '',
            bank_name: '',
            agent_id: '',
            group_id: '',
            page: 1,
            limit: 20,
            wx_ip: '',
            group_mark:''
        },
        todayApplys: true,
        list: [],
        sign: {

        },
        temp: {
            ip: "",
            end_time: "",
            add_time: ""
        },
        total_ip: {
            ip_count: 0,
            ip_sum_count: 0,
            ip_sunused: 0
        },
        wx_total_ip: {
            ip_count: 0,
            ip_sum_count: 0,
            ip_sunused: 0
        },
        checks: {
            check01: true,//启用
            check02: true,//通过
        },
        list01: [{}],
        sort_id: '3',
        agents_list: [{}],//代理数组
        total: 0,
        ips: [],
        IP_sum:0,
        wx_ips: [],
        groupList: [{}],
        todayApplyDetailList: [],//今日列表
        renewIpAmountDetailList: [{}],//三日列表
        ipList_temp:{
            ipList:[],
            total_amount:'',
            type:''
        },//IP申请数量
        renewIpList_temp:{//IP续费数量
            ipList:[],
            total_amount:'',
            type:''
        },
        renewWxIpList_temp:{//微信IP续费数量
            ipList:[],
            total_amount:'',
            type:''
        },
        wx_ipList_temp:{
            ipList:[],
            total_amount:'',
            type:''
        },//IP申请数量
        listQuery: {
            end_time: '',
            begin_time:''
        },
        todayApplyDetailList_id:''
    },
    mutations: {
        changeColorBg(state,payload){
            state.color_bg=payload
        },
        clearpageList_card(state,payload){
            state.input02.limit = 20
            state.input02.page = 1
        },
        renewStatus_card(state,payload){
            state.todayApplyDetailList_id=payload
        },
        getIpAmount_card(state,payload){
            state.ipList_temp={
                ipList:[],
                total_amount:'',
                type:''
            }
            for(var i in payload){
                if(payload[i] instanceof Object){
                state.ipList_temp.ipList.push(payload[i])
                }
            }
            state.ipList_temp.total_amount=payload.total_amount
            state.ipList_temp.type=payload.type
            // console.log(state.ipList_temp.type);
            
        },
        getRenewIpAmount_card(state,payload){
            state.renewIpList_temp={
                ipList:[],
                total_amount:'',
                type:''
            }
            for(var i in payload){
                if(payload[i] instanceof Object){
                state.renewIpList_temp.ipList.push(payload[i])
                }
            }
            state.renewIpList_temp.total_amount=payload.total_amount
            state.renewIpList_temp.type=payload.type
            // console.log(state.ipList_temp.type);
            
        },
        getRenewWxIpAmount_card(state,payload){
            state.renewWxIpList_temp={
                ipList:[],
                total_amount:'',
                type:''
            }
            for(var i in payload){
                if(payload[i] instanceof Object){
                state.renewWxIpList_temp.ipList.push(payload[i])
                }
            }
            state.renewWxIpList_temp.total_amount=payload.total_amount
            state.renewWxIpList_temp.type=payload.type
            // console.log(state.ipList_temp.type);
            
        },
        getWxipAmount_card(state,payload){
            state.wx_ipList_temp={
                ipList:[],
                total_amount:'',
                type:''
            }
            for(var i in payload){
                if(payload[i] instanceof Object){
                state.wx_ipList_temp.ipList.push(payload[i])
                }
            }
            state.wx_ipList_temp.total_amount=payload.total_amount
            state.wx_ipList_temp.type=payload.type
            // console.log(state.ipList_temp.type);
            
        },
        getAddtime_Endtime_card(state, payload) {

            let mm = (new Date().getMonth() + 1)< 10 ? '0' + (new Date().getMonth() +1): new Date().getMonth()+1;
            let mm01 = new Date().getMonth() + 2>12? 1:new Date().getMonth()+2;
            let yy = new Date().getFullYear()< 10 ? '0' + new Date().getFullYear() : new Date().getFullYear();
            let yy01 =mm01>12? new Date().getFullYear()+1:new Date().getFullYear();
            let dd = new Date().getDate();
            let hh = new Date().getHours();
            let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
            let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
            var value = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
            var value01 = yy01 + '-' + mm01 + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
            state.temp.add_time = value
            state.temp.end_time = value01
        },
        getUsableBankPayWxIp_card(state, payload) {
            state.wx_ips = payload.ips
            state.wx_total_ip.ip_count = payload.ip_count
            state.wx_total_ip.ip_sum_count = payload.ip_sum_count
            state.wx_total_ip.ip_sunused = payload.ip_sunused
        },
        renewIpAmountDetailList_card(state, payload) {
            state.renewIpAmountDetailList = payload
        },
        todayApplyDetailList_card(state, payload) {
            state.todayApplyDetailList = payload
        },
        changetodayApplys_card(state, payload) {
            state.todayApplys = payload
        },
        select_card(state, payload) {
            state.input02.group_id = ""
            state.groupList = [{}]
            for (var i = 0; i < state.agents_list.length; i++) {
                if (state.agents_list[i].id == payload) {
                    // console.log(state.agents_list[i]);
                    state.groupList = state.agents_list[i].group
                }
            }
        },
        cleartemp_card(state, payload) {
            state.temp = { ip: '', end_time: '', add_time: '' }
        },
        clear_group_id_card(state, payload) {
            state.input02.group_id = ''
        },
        changelimit_card(state, payload) {
            state.input02.limit = payload
        },
        changepage_card(state, payload) {
            state.input02.page = payload
        },
        changeCheck01_card(state, payload) {//启用/未启用
            // console.log(payload);
            // console.log(state.list[payload.id]);
            state.list[payload.id].state = payload.state
        },
        changeCheck02_card(state, payload) {//通过/未通过
            // console.log(payload);
            state.list[payload.id].is_test = payload.is_test
        },
        getSortList_card(state, payload) {//获取分类list
            state.list01 = payload
            state.sort_id=payload[0].id
        },
        getAgents_card(state, payload) {//获取代理数组
            state.agents_list = payload
        },
        getDataList_card(state, payload) {//获取表格数据

            state.list = payload.list
            var IP_sum=0
            state.list=payload.list.map((res,ins)=>{
                if(!res.ip_end_time){
                   res.ip_end_time='1977-01-01'
                }else{

                    IP_sum+=1
                }
                return res
            })
            state.IP_sum=IP_sum
            // console.log(state.list);
            // console.log(lists);
            state.total = payload.totalSum
        },
        getUsableBankPayIp_card(state, payload) {//获取分类list
            state.ips = payload.ip_info
            state.total_ip.ip_count = payload.ip_count
            state.total_ip.ip_sum_count = payload.ip_sum_count
            state.total_ip.ip_sunused = payload.ip_sunused
        },
        serchTime_card(state,payload){
            state.listQuery.begin_time=payload[0].trim()
            state.listQuery.end_time=payload[1].trim()
        },
        clearList_card(state,payload){
            state.list=[];
            state.ips=[];
        }
    },
    actions: {}
}
